<%@ page language="java"
	import="java.util.*,bc.swim2.ejb.entity.RegisteredUser"
	contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%
	RegisteredUser currentUser = (RegisteredUser) (session
			.getAttribute("currentSessionUser"));
	if (currentUser == null) {
%>
<body>Where are you going?
</body>
<%
	} else {
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Friends of Friends</title>
<style>
@import url(css/main.css);
</style>
</head>
<body>
	<div id="allContainer">
		<div id="titleContainer">
			<%%>
			<img src="img/swimScritta.gif" id="imageFloat" width=100px;
				height="100px">
			<h1 id="userHomeTitle">
				Welcome,
				<%=currentUser.getFirstName() + " "
						+ currentUser.getLastName()%>!
			</h1>
		</div>
		<div id="container">
			<div id="navigationContainer">
				<a href="MainServlet?to=RegisteredUserHome" id="linkRef">Home</a> <br />
				<a href="MainServlet?to=SearchHelp" id="linkRef">Search Help</a> <br />
				<a href="MainServlet?to=SearchUsers" id="linkRef">Search Users</a> <br />
				<a href="MainServlet?to=MyAbilities" id="linkRef">Declare/Remove
					ability</a> <br /> <a href="MainServlet?to=FriendshipRequests"
					id="linkRef">Friendship Requests</a> <br /> <a
					href="MainServlet?to=Friends" id="linkRef">Your Friends</a> <br />
				<a href="MainServlet?to=MyFeedback" id="linkRef">Feedback</a> <br />
				<a href="MainServlet?to=AbilityRequest" id="linkRef">Ability
					Request</a> <br /> <a href="LoginServlet?methodName=logout"
					id="linkRef">Logout</a>
			</div>
			<div id="actionContainer">

				<h1 id="listTitle">Maybe you know:</h1>
				<%
					List<RegisteredUser> users = (List<RegisteredUser>) request
								.getAttribute("friendsOfFriends");
						Map<Integer, String> frMap = (Map<Integer, String>) request
								.getAttribute("frOfFrMap");
				%><table>
					<%
						for (RegisteredUser ru : users) {
								String ruFirstName = ru.getFirstName();
								String ruLastName = ru.getLastName();
								int ruId = ru.getId();
								String fs = frMap.get(ruId);
								if (ruId == currentUser.getId()) {
								} else if (fs.equals("accepted")) {
								} else {
					%>
					<tr>

						<td><%=ruFirstName%></td>
						<td><%=ruLastName%></td>
						<%
							if (fs.equals("pending")) {
						%>
						<td><form action="FriendshipServlet" method="POST">
								<input type="hidden" name="methodName"
									value="indirectSendFriendshipRequest"> <input
									type="hidden" name="userId" value="<%=ruId%>"> <input
									type="submit" id="submitInputB" value="Add Friend" disabled>
							</form></td>
						<%
							} else if (fs.equals("noRequest")) {
						%>
						<td><form action="FriendshipServlet" method="POST">
								<input type="hidden" name="methodName"
									value="indirectSendFriendshipRequest"> <input
									type="hidden" name="userId" value="<%=ruId%>"> <input
									type="submit" id="submitInputA" value="Add Friend">
							</form></td>
						<%
							}
						%>
					</tr>
					<%
						}
							}
						}
					%>
				</table>
			</div>
		</div>
	</div>

</body>
</html>